﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MaLu.Common;
using MaLu.BusiLogic;
using System.Xml;
using MaLu.Framework.Common;

namespace MaluJg.web.ProjectFund
{
    public partial class item6 : ProjectPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            string projectname = string.Empty;
            string content = BLProject.GetProjectItem(Provider, ProjectID, "item6.aspx", ref projectname);
            if (content != string.Empty)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(content);
                XmlElement xe = document.SelectSingleNode("//项目名称") as XmlElement;                
                tbProjectName.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//商务标及技术标") as XmlElement;
                tbBiao.Text = Util.ReturnXml(xe.InnerText);

                xe = document.SelectSingleNode("//评委1") as XmlElement;
                tbPingWei1.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//评委2") as XmlElement;
                tbPingwei2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//年1") as XmlElement;
                tbYear1.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//月1") as XmlElement;
                tbMonth1.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//日1") as XmlElement;
                tbDay1.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//年2") as XmlElement;
                tbYear2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//月2") as XmlElement;
                tbMonth2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//日2") as XmlElement;
                tbDay2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//商务标1列表") as XmlElement;
                tbContents1.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//商务标2列表") as XmlElement;
                tbContents2.Text = Util.ReturnXml(xe.InnerText);
               
            }
        }

        private string FillContent()
        {
            string template = BLProject.GetTemplate(Provider, "item6.aspx");
            if (template != string.Empty)
            {

                XmlDocument document = new XmlDocument();
                document.LoadXml(template);
                XmlElement xe = document.SelectSingleNode("//项目名称") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbProjectName.Text.Trim());
                xe = document.SelectSingleNode("//商务标及技术标") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbBiao.Text.Trim());
                xe = document.SelectSingleNode("//评委1") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbPingWei1.Text.Trim());
                xe = document.SelectSingleNode("//评委2") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbPingwei2.Text.Trim());
                xe = document.SelectSingleNode("//年1") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbYear1.Text.Trim());
                xe = document.SelectSingleNode("//月1") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbMonth1.Text.Trim());
                xe = document.SelectSingleNode("//日1") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbDay1.Text.Trim());
                xe = document.SelectSingleNode("//年2") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbYear2.Text.Trim());
                xe = document.SelectSingleNode("//月2") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbMonth2.Text.Trim());
                xe = document.SelectSingleNode("//日2") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbDay2.Text.Trim());
                xe = document.SelectSingleNode("//商务标1列表") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbContents1.Text.Trim());
                xe = document.SelectSingleNode("//商务标2列表") as XmlElement;
                xe.InnerText = Util.ReplaceXml(tbContents2.Text.Trim());
                return document.OuterXml;
            }
            else
                return string.Empty;

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BLProject.SaveProjectItem(Provider, ProjectID, "item6.aspx", FillContent());


            string msg = "已保存!";

            string script = "<script>alert('" + msg + "');</script>";
            ClientScript.RegisterStartupScript(this.GetType(), "Close", script);


        }
    }
}
